// components/shipin-card/shipin-card.js
import formatTime from '../../style/formatTime.js'
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    shipin:Object,
  },
  observers: {
    ['shipin.createTime'](val) {
      if (val) {
        // console.log(val)
        this.setData({
          _createTime: formatTime(new Date(val))
        })
      }
    }
  },
  /**
   * 组件的初始数据
   */
  data: {
    _createTime:'',
  },

  /**
   * 组件的方法列表
   */
  methods: {
  // 视频播放
  videoPlay(event){
    var index = video.getDataSet(event, 'index');

    if (!this.data.videoIndex) { // 没有播放时播放视频
        this.setData({
            videoIndex: index
        })          
        var videoContext = wx.createVideoContext('video' + index)
        videoContext.play()
    } else {
        var videoContextPrev = wx.createVideoContext('video' + this.data.videoIndex)
        videoContextPrev.stop()
        this.setData({
            videoIndex: index
        })  
        var videoContextCurrent = wx.createVideoContext('video' + index)
        videoContextCurrent.play()
    }
},
jvbao(event){
  wx.navigateTo({
    url: '/pages/index/jvbao/jvbao?tieziid=' + this.data.shipin._id +'&ip=' + this.data.tupian.ip +'&openid='+this.data.shipin._openid,
  })
}
  }
})
